package com.ycwl.aiLive_2d.model.snowFlake;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author Created by liuhongguang on 2019年10月27日
 * @Description
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class UniqueId implements Serializable {

    /**
     * 0     +   41       +   5             +       5           +       12
     * 固定  +  时间戳    +   工作机器ID     +     数据中心ID    +      序列号
     */

    private static final long serialVersionUID = 8632670752020316524L;

    /**
     * 工作机器ID、数据中心ID、序列号、上次生成ID的时间戳
     */
    @ApiModelProperty(value = "机器ID")
    private long machineId;

    @ApiModelProperty(value = "数据中心ID")
    private long datacenterId;

    @ApiModelProperty(value = "毫秒内序列")
    private long sequence;

    @ApiModelProperty(value = "时间戳")
    private long timestamp;

    @Override
    public String toString() {
        return "UniqueIdRespVo{" +
                "服务机器ID=" + machineId +
                ", 数据中心ID=" + datacenterId +
                ", 毫秒内的序列=" + sequence +
                ", 生成时间与预设时间戳间隔=" + timestamp +
                '}';
    }
}
